package com.xpgk.mvc.standardCustomer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Record;
import com.xpgk.constant.ConstantSplitPage;
import com.xpgk.dto.SplitPage;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.leaveCustomer.LeaveCustomerSQL;
import com.xpgk.mvc.leaveCustomer.LeaveCustomerXLS;
import com.xpgk.mvc.organization.Organization;
import com.xpgk.mvc.user.User;

public class StandardCustomerController extends BaseController{
	public void index(){
		Organization organ=Organization.dao.findById(getCUserOrganIds());
		setAttr("organization",organ);
		render("standardCustomer.html");
	}
	/**
	 * 查询标体顾客
	 */
	public void queryStandard(){
		String json = paging(splitPage, StandardCustomerSQL.standardCustomer_splitPageSelect, StandardCustomerSQL.standardCustomer_splitPageFrom);		
		renderJson(json);
	}
	/**
	 * 导出表格
	 */
	public void  excel()
	{	
		SplitPage  splitPage=new SplitPage();
		String  organIds=getPara("organIds");
		String  startDate=getPara("startDate");
		String  endDate=getPara("endDate");
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("organIds", organIds);
		param.put("startDate", startDate);
		param.put("endDate", endDate);
		splitPage.setPageSize(ConstantSplitPage.default_maxSize);
		splitPage.setQueryParam(param);
		String json = paging(splitPage, StandardCustomerSQL.standardCustomer_splitPageSelect, StandardCustomerSQL.standardCustomer_splitPageFrom);
		List<Record>  list=(List<Record>)splitPage.getList();
		//搜索条件
		Organization  organ = Organization.dao.findById(organIds);
		String  search="开始日期："+startDate+"结束日期："+endDate+",门店："+organ.getStr(Organization.column_name)+",导出人员："+getCUser().getStr(User.column_name); 
		render(new StandardCustomerXLS(list,search,"标体顾客表"));
	}
}
